﻿using System.Linq;
using System.Web.Security;

namespace SoftSource.Timecard.Web.Providers
{
    public class TimecardRoleProvider : RoleProvider
    {

        private string _timecardApplicationName = "TimecardApplication";

        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            string value = config["applicationName"];
            if (!string.IsNullOrEmpty(value))
            {
                _timecardApplicationName = value;
            }
            base.Initialize(name, config);
        }

        public override string ApplicationName
        {
            get { return _timecardApplicationName; }
            set { _timecardApplicationName = value; }
        }

        // TEST
        public override bool IsUserInRole(string username, string roleName)
        {
            return true;
        }

        public override string[] GetRolesForUser(string username)
        {
            string[] roles = DAL.Users.GetUserRoles(username).ToArray();
            return roles;
        }

        #region NOT Implemented Methods

        public override void CreateRole(string roleName)
        {
            throw new System.NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new System.NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new System.NotImplementedException();
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new System.NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new System.NotImplementedException();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new System.NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new System.NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new System.NotImplementedException();
        }

        #endregion
    }
}
